import request from '@/api/axios'
import {AxiosPromise} from 'axios'
import {DataRes, Paging} from '@/api/config'

// 项目编码 itemCode
// 项目名称 itemName
// 英文简称	enShortName
// 检查类型 checkType checkTypeName

// 单位名称	unitName
// 检查结果类型 inspectResultType
// 精度 precision
// 单位 unit
// 结果类型 resultType
// 是否固定项目：为1是固定 isFixed

//体检项目分页查询数据定义
export interface GetPhysicalItemList extends Paging{
  itemName?:string|null
  itemCode?:string|null
  checkType?:string|null
  enShortName?:string|null
  checkTypeName?:string|null
  isFixed?:string|null
  resultType?:string|null
  unit?:string|null
  precision?:string|null
  inspectResultType?:string|null
  unitName?:string|null
}

// 搜索数据定义
export interface SearchPhysicalItemFromData{
  itemName?:string|null,
  itemCode?:string|null
  checkType?:string|null,
}

//表头按钮定义
export type TableOperation='add'

// 体检项目基本信息
export interface BasePhysicalItemInfor{
  itemName:string,
  itemCode:string,
  enShortName?:string,
  checkType:string,
  checkTypeName:string
  isFixed:string
  resultType?:string
  unit?:string
  precision?:string
  inspectResultType:string
  unitName?:string
}

//体检项目信息
export interface PhysicalItemInfor extends BasePhysicalItemInfor{
  id:number
}

export type PhysicalItemFormInfor = Partial<PhysicalItemInfor>

export interface PhysicalItemInforList {
  size:number
  total:number
  records:Array<PhysicalItemInfor>
}
//获取体检项目管理列表事件
export const getPhysicalItemList = (params:GetPhysicalItemList):AxiosPromise<DataRes<PhysicalItemInforList>> => {
  return request({
    url:'/api/item/page',
    method:'get',
    params
  })
}

//保存修改体检项目信息事件
export const savePhysicalItemInfor = (data:PhysicalItemFormInfor):AxiosPromise<DataRes<undefined>> => {
  return request({
    url:'/api/item/save',
    method:'post',
    data
  })
}

// 删除体检项目信息事件
export const deletePhysicalItem = (params:{itemId:string}):AxiosPromise<DataRes<undefined>> => {
  return request({
    url:'/api/item/delete',
    method:'post',
    params
  })
}